home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14412 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.6 KB

  1. Path: news.asiaonline.net!usenet
  2. From: samsona@asiaonline.net (Samson Lin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Can't Display PopUp Window
  5. Date: Sat, 30 Mar 1996 09:01:25 GMT
  6. Organization: Reader's Digest Far East
  7. Message-ID: <4jit49$pea@news.asiaonline.net>
  8. NNTP-Posting-Host: ip101.asiaonline.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi,
  12.  
  13. I am writing a Window C program.  I meet a problem in displaying popup
  14.  
  15. window.
  16.  
  17. The program is a quite simple program.  It is a phone book to record
  18. name, address, & tel. no.  It has a menu bar with 2 options:
  19.  
  20.    ABOUTMENU MENU
  21.    {
  22.       MENUITEM "Load/Save PhoneBk    ", CM_LOAD_SAVE
  23.       MENUITEM "Exit", CM_EXIT
  24.    }
  25.  
  26. CM_EXIT is for program exit while CM_LOAD_SAVE is for displaying
  27. another window for file loading & saving.  The popup window is
  28. designed like the popup window after you press "Save as" command in
  29. Word or Excel.
  30.  
  31. The followings are the codes for calling the popup window dialog &
  32. exit under WM_COMMAND, switch statements; as well as the LOAD/SAVE
  33. dialog 
  34. function "LoadSaveDlgProc":
  35.  
  36.   case CM_LOAD_SAVE:
  37.   {
  38.     FARPROC LoadSaveDlg = 
  39.          MakeProcInstance((FARPROC)LoadSaveDlgProc, hInstance);
  40.  
  41.     if (hInstance == NULL)
  42.         MessageBox(hwnd, "MakeProcInstance Failed",    
  43.                    "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  44.     else
  45.         MessageBox(hwnd, "MakeProcInstance Successful", 
  46.                    "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  47.  
  48.     DialogBox(hInstance, "SAVEDLG", hwnd, (DLGPROC)LoadSaveDlg);
  49.  
  50.     MessageBox(hwnd, "End of LOAD/SAVE DialogBox execution",
  51.                "DEBUG CM_LOAD_SAVE", MB_OK|MB_ICONEXCLAMATION);
  52.   
  53.     FreeProcInstance(LoadSaveDlg);
  54.   }
  55.   break;
  56.  
  57.   case CM_EXIT:
  58.   {
  59.     DestroyWindow(hwnd);
  60.   }
  61.   break;
  62.   .......
  63.  
  64. //-------------------------------------------------------------------
  65.   BOOL CALLBACK LoadSaveDlgProc(HWND hDlg, WORD Message,
  66.                 WPARAM wParam, LPARAM lParam)
  67.   {
  68.     .......
  69.   }
  70.  
  71. During the testing period, everything functioned smoothly.  I could
  72. display the LOAD/SAVE popup window by pressing MENUITEM "Load/Save
  73. PhoneBk" & exit the program normally by pressing MENUITEM "Exit".  The
  74. testing was done during I was in the Borland C++ 4.5 environment.
  75.  
  76. After the testing, I quitted Borland environment, open File Manager,
  77. clicked the phone book program line to have it executed.  All things
  78. got normal results.
  79.  
  80. Immediately, I quitted Windows to dos, & then enter Windows once
  81. again. 
  82. I opened File Manager & executed the same program.  The program still
  83. ran BUT when I clicked the LOAD/SAVE menuitem, the LOAD/SAVE popup
  84. window didn't appear!  The EXIT menuitem still worked instead.
  85.  
  86. So I added several MessageBox statements inside the "CM_LOAD_SAVE"
  87. module and test the program once again.  I quitted Window and entered
  88. once again, repeated the same things.  All messages were displayed
  89. before and after the following statement (shown in the source code 
  90. above, which calls the LOAD/SAVE dialog),
  91.  
  92.      DialogBox(hInstance, "SAVEDLG", hwnd, (DLGPROC)LoadSaveDlg);
  93.  
  94. but the DialogBox statement didn't execute, i.e. LoadSaveDlg not
  95. called.
  96.  
  97. If I repeat the following steps, I can always wake up the LOAD/SAVE 
  98. popup window :
  99.  
  100.    (1) Run Borland C++ IDE
  101.    (2) Run phone book program
  102.    
  103.                OR
  104.  
  105.    (1) Run Borland C++ IDE
  106.    (2) Quit Borland C++ IDE
  107.    (3) Run phone book program
  108.  
  109. If I don't run Borland C++ beforehand, the program still works but I 
  110. can't see the LOAD/SAVE popup window when I click the LOAD/SAVE menu
  111. item.  
  112.  
  113. Why the above case happens?  My pc configuration is Pentium 100,
  114. 8MB ram, Chinese Win v3.1 with Win32s.
  115.  
  116. Samson
  117. Reader's Digest Asso. Far East
  118. (samsona@asiaonline.net)
  119.  
  120.